<?php

header ( "Content-type:text/html;charset=utf-8" );
$json_string = file_get_contents('install_sql.json');
$dataxxx = json_decode($json_string, true);
$link=mysqli_connect($dataxxx[1],$dataxxx[2],$dataxxx[3]);//链接数据库

if($link)
{
    $select=mysqli_select_db($link,$dataxxx[4]);//选择数据库
echo mysqli_error();
  if($select)
  {
    if(isset($_POST["subl"]))
    {
      $name=$_POST["usernamel"];
      $password=$_POST["passwordl"];
      if($name==""||$password=="")//判断是否为空
      {
echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."请填写正确的信息！"."\"".")".";"."</script>"; echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."../login.php"."\""."</script>";
        exit;
      }
      $str="select password from `OurShareUserName` where username="."'"."$name"."'";
      $str1="select vip from `OurShareUserName` where username="."'"."$name"."'";
      mysqli_query('SET NAMES UTF8');
	  $result1=mysqli_query($link,$str1);
	  $result=mysqli_query($link,$str);
      $pass=mysqli_fetch_row($result);
      $pass1=mysqli_fetch_row($result1);
      $pa=$pass[0];
      $pas=$pass1[0];
      if($pa==$password)//判断密码与注册时密码是否一致
      {
setcookie("user", "1", time()+3600000);
setcookie("name", $name, time()+3600000);
setcookie("pass", $password, time()+3600000);
setcookie("vip", $pas, time()+3600000);

echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."../index.php"."\""."</script>";
      }
      { 
      echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."登录失败！"."\"".")".";"."</script>"; echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."../login.php"."\""."</script>";
      }
    }  
  }
}
?>